"""
医院数据模型
"""
from sqlalchemy import Column, Integer, String, SmallInteger, DateTime
from sqlalchemy.sql import func

from  core.database import Base


class Hospital(Base):
    """医院表"""
    __tablename__ = "hospitals"
    
    id = Column(Integer, primary_key=True, index=True, comment="医院ID")
    hospital_name = Column(String(200), nullable=False, unique=True, index=True, comment="医院名称")
    invite_code = Column(String(50), nullable=False, unique=True, index=True, comment="邀请码")
    status = Column(SmallInteger, nullable=False, default=1, comment="状态 1-正常 0-禁用")
    created_at = Column(
        DateTime(timezone=True),
        nullable=False,
        server_default=func.now(),
        comment="创建时间"
    )
    updated_at = Column(
        DateTime(timezone=True),
        nullable=False,
        server_default=func.now(),
        onupdate=func.now(),
        comment="更新时间"
    )
    
    def __repr__(self):
        return f"<Hospital(id={self.id}, name={self.hospital_name}, invite_code={self.invite_code})>"

